toStrictlyPositiveIntOrNull

@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun Number.toStrictlyPositiveIntOrNull(): StrictlyPositiveInt?

Returns this number as a StrictlyPositiveInt, which may involve rounding or truncation, or returns null if this number is negative.

Here's some usage examples:

var result: StrictlyPositiveInt? = 1.toStrictlyPositiveIntOrNull()
println(result) // 1

result = 0.toStrictlyPositiveIntOrNull()
println(result) // null

result = (-1).toStrictlyPositiveIntOrNull()
println(result) // null

You can use the toStrictlyPositiveIntOrThrow function for throwing an IllegalArgumentException instead of returning null when this number is negative.